package RadianceM.DistributionSystem.handler;

import RadianceM.DistributionSystem.voto.result.DSResult;
import RadianceM.DistributionSystem.voto.result.ResultCode;
import jakarta.validation.ConstraintViolationException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

	@ExceptionHandler(value = ConstraintViolationException.class)
	@ResponseBody
	public DSResult<Object> handleConstraintViolationException(ConstraintViolationException ex) {
		log.error("\nConstraintViolationException - 参数效验异常:\t"+ ex.getMessage());
		return DSResult.fail(ResultCode.PARAM_ERROR);
	}
}
